var db    = {};
var mysql = require('mysql');
var pool  = mysql.createPool({ // 创建连接池
    connectionLimit : 10,
    host            : 'localhost',
    user            : 'root',
    password        : '123456',
    database        : 'stock'
});
db.query = function(sql,params, callback){
    pool.query(sql,params, function(err, rows, fields) {
        if (err) {
            console.log(err);
            callback(err, null);
            return;
        };
        callback(null, rows, fields);
    });
}
module.exports = db;